package testcase.app;

import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import api.app.ChangeChannel;
import common.Host;
import common.TestData;

/**
 * 帮忙医是否切换公有云ChangeChannel接口测试用例
 * @author lipeng
 *
 */
public class TestChangeChannel
{
	/**
	 * 帮忙医是否切换公有云ChangeChannel接口测试环境数据驱动
	 * @return 
	 * @throws Exception
	 */
    @DataProvider(name = "Test")
    public static String[][] testChangeChannelDataProvider()throws Exception{
    	Host.setup("Test");
    	TestData td = new TestData("app/TestChangeChannel.xml");
    	return td.getParam();
    }
    /**
     * 帮忙医是否切换公有云ChangeChannel接口
     * @param casename  --用例名称
     * @param token     --调用接口的token
     * @throws Exception
     */
    @Test(dataProvider="Test",groups={"Test"})
    public void testChangeChannelTestCase(String casename,String token)throws Exception{
    	//调用接口并将接口返回数据转换成json格式
    	String result = ChangeChannel.get(token);
        JSONObject jsonResult;
        if(result == null || result.isEmpty()){
        	jsonResult = null;
        }
        else {
			jsonResult = new JSONObject(result);
		}
        
        //设置检查点 
        switch (casename)
		{
			case "Success":
				Assert.assertFalse(jsonResult.getJSONObject("Data").getBoolean("isChange"), "false");
				break;
			default:
				break;
		}
    }
}
